
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>4.2 配置 HBase 支持 Phoenix 创建二级索引 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="43-chuang-jian-suo-yin.html" />
    
    
    <link rel="prev" href="41-hbase-de-er-ji-suo-yin.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    第 1 章 Phoenix 简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1.html">
            
                <a href="../chapter1.html">
            
                    
                    第 2 章 Phoenix 快速入门
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../chapter1/21-an-zhuang-bu-shu.html">
            
                <a href="../chapter1/21-an-zhuang-bu-shu.html">
            
                    
                    2.1 安装部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../chapter1/22-phoenix-biao-cao-zuo.html">
            
                <a href="../chapter1/22-phoenix-biao-cao-zuo.html">
            
                    
                    2.2 Phoenix 表操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../chapter1/23-phoenix-biao-ying-she.html">
            
                <a href="../chapter1/23-phoenix-biao-ying-she.html">
            
                    
                    2.3 Phoenix 表映射
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.html">
            
                <a href="../di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.html">
            
                    
                    第 3 章 Phoenix 图形化工具: Squirrel
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin.html">
            
                <a href="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin.html">
            
                    
                    第 4 章 Phoenix 创建 HBase 二级索引
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="41-hbase-de-er-ji-suo-yin.html">
            
                <a href="41-hbase-de-er-ji-suo-yin.html">
            
                    
                    4.1 HBase 的二级索引
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.2" data-path="42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.html">
            
                <a href="42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.html">
            
                    
                    4.2 配置 HBase 支持 Phoenix 创建二级索引
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="43-chuang-jian-suo-yin.html">
            
                <a href="43-chuang-jian-suo-yin.html">
            
                    
                    4.3 Phoenix 创建索引
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >4.2 配置 HBase 支持 Phoenix 创建二级索引</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="42-&#x914D;&#x7F6E;-hbase-&#x652F;&#x6301;-phoenix-&#x521B;&#x5EFA;&#x4E8C;&#x7EA7;&#x7D22;&#x5F15;">4.2 &#x914D;&#x7F6E; HBase &#x652F;&#x6301; Phoenix &#x521B;&#x5EFA;&#x4E8C;&#x7EA7;&#x7D22;&#x5F15;</h1>
<p>&#x9700;&#x8981;&#x5148;&#x7ED9; HBase &#x914D;&#x7F6E;&#x652F;&#x6301;&#x521B;&#x5EFA;&#x4E8C;&#x7EA7;&#x7D22;&#x5F15;</p>
<h2 id="&#x6B65;&#x9AA4;-1-&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x914D;&#x7F6E;&#x5230;-hbase-&#x7684;-hregionerver-&#x8282;&#x70B9;&#x7684;-hbase-sitexml">&#x6B65;&#x9AA4; 1: &#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x914D;&#x7F6E;&#x5230; HBase &#x7684; Hregionerver &#x8282;&#x70B9;&#x7684; hbase-site.xml</h2>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- phoenix regionserver &#x914D;&#x7F6E;&#x53C2;&#x6570; --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>hbase.regionserver.wal.codec<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>hbase.region.server.rpc.scheduler.factory.class<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">description</span>&gt;</span>Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates<span class="hljs-tag">&lt;/<span class="hljs-name">description</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>hbase.rpc.controllerfactory.class<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">description</span>&gt;</span>Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates<span class="hljs-tag">&lt;/<span class="hljs-name">description</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span>
</code></pre>
<h2 id="&#x6B65;&#x9AA4;-2-&#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x914D;&#x7F6E;&#x5230;-hbase-&#x7684;-hmaster-&#x8282;&#x70B9;&#x7684;-hbase-sitexml">&#x6B65;&#x9AA4; 2: &#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x914D;&#x7F6E;&#x5230; HBase &#x7684; Hmaster &#x8282;&#x70B9;&#x7684; hbase-site.xml</h2>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- phoenix master &#x914D;&#x7F6E;&#x53C2;&#x6570; --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>hbase.master.loadbalancer.class<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>org.apache.phoenix.hbase.index.balancer.IndexLoadBalancer<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>hbase.coprocessor.master.classes<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>org.apache.phoenix.hbase.index.master.IndexMasterObserver<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span>
</code></pre>
<h2 id="&#x6B65;&#x9AA4;-3-&#x6D4B;&#x8BD5;&#x662F;&#x5426;&#x652F;&#x6301;">&#x6B65;&#x9AA4; 3: &#x6D4B;&#x8BD5;&#x662F;&#x5426;&#x652F;&#x6301;</h2>
<blockquote>
<p>&#x51C6;&#x5907;&#x6570;&#x636E;:</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> user_1(<span class="hljs-keyword">id</span> <span class="hljs-built_in">varchar</span> primary <span class="hljs-keyword">key</span>, <span class="hljs-keyword">name</span> <span class="hljs-built_in">varchar</span>, addr <span class="hljs-built_in">varchar</span>)

<span class="hljs-keyword">upsert</span> <span class="hljs-keyword">into</span> user_1 <span class="hljs-keyword">values</span> (<span class="hljs-string">&apos;1&apos;</span>, <span class="hljs-string">&apos;zs&apos;</span>, <span class="hljs-string">&apos;beijing&apos;</span>);
upsert into user_1 values (&apos;2&apos;, &apos;lisi&apos;, &apos;shanghai&apos;);
upsert into user_1 values (&apos;3&apos;, &apos;ww&apos;, &apos;sz&apos;);
</code></pre>
<blockquote>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;, &#x53EA;&#x8981; rowkey &#x652F;&#x6301;&#x7D22;&#x5F15;(&#x5C31;&#x662F;&#x4E0A;&#x9762;&#x7684; id)</p>
</blockquote>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566869340.png" alt=""></p>
<blockquote>
<p>&#x5176;&#x4ED6;&#x5B57;&#x6BB5;&#x662F;&#x4E0D;&#x652F;&#x6301;&#x7D22;&#x5F15;&#x7684;:</p>
</blockquote>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566869403.png" alt=""></p>
<blockquote>
<p>&#x7ED9; name &#x5B57;&#x6BB5;&#x6DFB;&#x52A0;&#x7D22;&#x5F15;:</p>
</blockquote>
<pre><code class="lang-sql"><span class="hljs-keyword">create</span> <span class="hljs-keyword">index</span> idx_user_1 <span class="hljs-keyword">on</span> user_1(<span class="hljs-keyword">name</span>)
</code></pre>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566870107.png" alt="">
&#x6CE8;&#x610F;: &#x8FD9;&#x79CD;&#x7D22;&#x5F15;, &#x5BF9; <code>name</code> &#x521B;&#x5EFA;&#x7684;&#x7D22;&#x5F15;, &#x5219;&#x67E5;&#x8BE2;&#x7684;&#x65F6;&#x5019;&#x4E5F;&#x5FC5;&#x987B;&#x53EA;&#x67E5;&#x8BE2; <code>name</code> &#x5B57;&#x6BB5;.</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="41-hbase-de-er-ji-suo-yin.html" class="navigation navigation-prev " aria-label="Previous page: 4.1 HBase 的二级索引">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="43-chuang-jian-suo-yin.html" class="navigation navigation-next " aria-label="Next page: 4.3 Phoenix 创建索引">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"4.2 配置 HBase 支持 Phoenix 创建二级索引","level":"1.4.2","depth":2,"next":{"title":"4.3 Phoenix 创建索引","level":"1.4.3","depth":2,"path":"di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/43-chuang-jian-suo-yin.md","ref":"di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/43-chuang-jian-suo-yin.md","articles":[]},"previous":{"title":"4.1 HBase 的二级索引","level":"1.4.1","depth":2,"path":"di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/41-hbase-de-er-ji-suo-yin.md","ref":"di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/41-hbase-de-er-ji-suo-yin.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.md","mtime":"2019-08-27T01:43:53.173Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-08-27T02:14:08.566Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

